<?php

namespace Controller\UC;

class Pager extends \Lib\Core\Controller {

	public function actionIndex() {

		/*$pager = $this->getUCParam('pager');
		$this->assign('pager', $pager);
		$this->display();*/
        $pager = $this->getUCParam('pager');
        $size = 7;
        $pageCount = $pager->pageCount;
        $page = $pager->currentPage;
        $mid = ceil($size / 2) - 1;
        $start = $page - $mid;
        if ($start < 1) {
            $start = 1;
        }
        $end = $start + $size - 1;
        if ($end > $pageCount) {
            $end = $pageCount;
        }

        $this->assign('start', $start);
        $this->assign('end', $end);
        $this->assign('pager', $pager);
        $this->display();
	}
    public function pager($pager) {
        $size = 7;
        $pageCount = $pager->pageCount;
        $page = $pager->currentPage;
        $mid = ceil($size / 2) - 1;
        $start = $page - $mid;
        if ($start < 1) {
                $start = 1;
        }
        $end = $start + $size - 1;
        if ($end > $pageCount) {
                $end = $pageCount;
        }

        $this->assign('start', $start);
        $this->assign('end', $end);
        $this->assign('pager', $pager);
        $this->display('Pager1');
}

}